<?php
class Role extends Zend_Db_Table {
	protected $_name = 'cc_role';
	private $db;
	
	/**
	 * 
	 * @access public
	 * @return 
	 */
	public function __construct(){
		$this->db = Zend_Db_Table::getDefaultAdapter();
		parent::_setup();
	}
	
	/**
	 * 取所有角色
	 * @access public
	 * @return 
	 */
	public function getAllRole(){
		$role = $this->fetchAll();
		$roleArr = $role->toArray();
		return $roleArr;
	}
	
	/**
	 * 
	 * @access public
	 * @return 
	 */
	public function getRoleById($id){
		$where = $this->db->quoteInto("id=?",$id);
		$row = $this->fetchRow($where);
		$roleArr = $row->toArray();
		return $roleArr;
	}
	
	/**
	 * 新增角色
	 * @access public
	 * @var array
	 * @return int
	 */
	public function insRole($data){
		$lastid = $this->insert($data);
		return $lastid;
	}
	
	/**
	 * 删除角色
	 * @access public
	 * @return int
	 */
	public function delRole($id){
		$where = $this->db->quoteInto("id=?",$id);
		$lastid = $this->delete($where);
		return $lastid;
	}
	
	/**
	 * 修改角色
	 * @access public
	 * @return 
	 */
	public function updRole($data,$id){
		$where = $this->db->quoteInto("id=?",$id);
		$lastid = $this->update($data,$where);
		return $lastid;
	}
}
?>